﻿using Jenkins.Common;
using Jenkins.Data;
using Jenkins.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace Jenkins
{
    public sealed partial class ViewDetailPage : LayoutAwarePage
    {
        public ViewDetailPage()
        {
            this.InitializeComponent();
        }

        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            var group = JenkinsDataSource.GetGroup((String)navigationParameter);
            this.DefaultViewModel["Group"] = group;
            this.DefaultViewModel["Items"] = group.Items;
        }

        void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var itemId = (e.ClickedItem as JenkinsJobDataItem).UniqueId;
            this.Frame.Navigate(typeof(JobDetailPage), itemId);
        }
    }
}
